Dynomotion

Group: DynoMotion Message: 1969 From: frank_19_88 Date: 10/14/2011
Subject: Kanalog Spindle Control Mach 3
Hello,

Finally I am programming the spindle in Mach3.

I have an DAC motor so i am using 'SpindleMach3DAC.c' to start.
My motor driver give's a signal (to bit 143) when he is on the right speed.

Now I want Mach3 to wait for this signal before running the next G-Code.
So I added the following lines to 'SpindleMach3DAC.c' :

ClearBit(157)//Show me that 'SpindleMach3DAC.c' is started
while(ReadBit(143)) //Wait for write speed
SetBit(157)//Show me that SpindleMach3DAC.c is not completed

But when I test this on Mach3 with the following code:
S150
S1500
S150
S1500

Mach3 jump's write true it.
When Mach3 is finished Bit 157 is reseted.
If I switch bit143 on after a minute it switches bit 157 on. (Because 'SpindleMach3DAC.c' was still running)

Is it possible to hold the G-Code until bit(143) is switched on after changing the spindle speed?

Thank you,

Frank
Group: DynoMotion Message: 1972 From: Tom Kerekes Date: 10/14/2011
Subject: Re: Kanalog Spindle Control Mach 3
Hi Frank,
 
KFLOP User programs launched from Spindle Commands or NotifyPlugins() calls are non-blocking.  They simply launch the User Program or possibly even queue them to be launched later if the thread is not available.  If we blocked the call until the program finished Mach3 would freeze until we returned which usually would be a bad thing.
 
The only solution I can think of would require you to add an M code VB macro after each S command.  You could then assign VB code to that Macro to loop sleeping until your input bit comes on.  You would need to configure the IO 143 as a Mach3 Input.  (Note that in Mach3 for KFLOP IO numbers greater than or equal to 128 - subtract 128 and specify port #2 instead of #1)
 
Does that work for you?
 
Rergards
TK